<template>
	<div id="footer">
		<router-link to="/home/index/00">
			<div @click="jump(0)">
				<img :src="cur == 0 ? 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Home_checked@2x.png' : 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Home_unselected@2x.png'" />
				<span :class="cur ==0 ? 'active' : '' ">首页</span>
				
			</div>
		</router-link>
		<router-link to="/home/newProduct" >
			<div @click="jump(1)">
				<img :src="cur == 1 ? 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/New_checked@2x.png' : 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/New_unselected@2x.png'" />
				<span :class="cur == 1 ? 'active' : '' ">新品</span>	
			</div>
		</router-link>
		<router-link to="/home/hot">
			<div @click="jump(2)" style="position: relative;">
				<img :src="cur == 2 ? 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Hot_checked@2x.png' : 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Hot_unselected@2x.png'" />
				<span :class="cur ==2 ? 'active' : '' ">热榜</span>
			</div>
		</router-link>
		<router-link to="/newActivity">
			<div @click="jump(3)" style="position: relative;">
				<img :src="cur == 3 ? 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Message_checked@2x.png' : 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Message_unselected@2x.png'" />
				<span :class="cur ==3 ? 'active' : '' ">活动</span>
				<span id="carNum" v-if="carNum">
					{{carNum}}
				</span>
			</div>
		</router-link>
		<router-link to="/home/my">
			<div @click="jump(4)">
				<img :src="cur == 4 ? 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Mine_checked@2x.png' : 'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/Mine_unselected@2x.png'" />
				<span :class="cur == 4 ? 'active' : '' ">我的</span>
			</div>
		</router-link>
	</div>
</template>

<script>
	import Store from "../store/store.js";
    import config from "../config/config.js";
	export default{
		data(){
			return{
				cur:0,
				carNum: Store.getState().carNum,
				path:''
			}
		},
		methods:{
			jump(index){
				this.cur = index;
				sessionStorage.setItem("cur",index);
			},
			change(){
				var path = this.$route.path;
				switch (path){
					case "/home/index/00":
						sessionStorage.setItem("cur",0)
						this.cur = 0;
						break;
					case "/home/newProduct":
						sessionStorage.setItem("cur",1)
						this.cur = 1;
						break;
					case "/home/shopping":
						sessionStorage.setItem("cur",2)
						this.cur = 2;
						break;
					case "/talking":
						sessionStorage.setItem("cur",3)
						this.cur = 3;
						break;
					case "/home/my":
						sessionStorage.setItem("cur",4)
						this.cur = 4;
						break;
					default:
						break;
				}
			}
		},
		mounted(){
			Store.subscribe(() => {
				this.carNum = Store.getState().carNum;
			})
		},
		activated(){
			this.cur = sessionStorage.getItem("cur") ? sessionStorage.getItem("cur") : 0;
		},
		watch:{
				"$route":"change",
		}
	}
</script>

<style>
</style>